﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MarryImageAdd.aspx.cs" Inherits="Com.CMS263.Web.manage.MarryInfo.MarryImageAdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <link href="../common/validator.css" rel="stylesheet" type="text/css" />

    <script src="../../js/Calendar1.js" type="text/javascript"></script>
    <script src="/js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="/js/common.js" type="text/javascript"></script>
    <style type="text/css">
        .style1
        {
        	text-align:center;
        }
        .style2
        {
            text-align: right;
        }
    </style>
     <style type="text/css">
    .preview_fake{
             filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);     
    }     
         #SortId
         {
             width: 150px;
         }
     </style>
    <script language="javascript" type="text/javascript">
        $(function() {
            $("#updateImage").hide();
        })
        function save() {
            if ($("#Title").val().length < 1) {
                alert("照片名称必填！");
                $("#Title").focus();
                return false;
            } else if ($("#FilePath").val().length < 1) {
                alert("请上传照片！");
                $("#FilePath").focus();
                return false;
            } else {
                return true;
            }
        }
        function onUploadImgChange(sender, width, height, index) {
            $("#updateImage").show();
            $("#headPic").val($(sender).val());
            try {
                index = index == undefined ? "" : index;
                if (!sender.value.match(/.jpg|.gif|.png|.bmp/i)) {
                    alert('请上传.jpg|.gif|.png|.bmp类型的图片');
                    return false;
                }

                var objPreview = $(".preview_pic" + index);
                var objPreviewFake = document.getElementById('preview_fake' + index);

                if (sender.files && sender.files[0]) {
                    objPreview.show();
                    objPreview.attr("width", width);
                    objPreview.attr("height", height);

                    objPreview.attr("src", sender.files[0].getAsDataURL());



                } else if (objPreviewFake.filters) {
                    sender.select();
                    var imgSrc = document.selection.createRange().text;
                    objPreviewFake.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = imgSrc;

                    objPreviewFake.style.width = width + 'px';
                    objPreviewFake.style.height = height + 'px';
                    objPreview.hide();
                    sender.blur();
                }
            } catch (ex) {
                alert(ex);
                alert("图片加载失败！");
            }
        }
        function checkNum(obj) {
            var tempstr;
            //先把非数字的都替换掉，除了数字和.   
            tempstr = obj.value.replace(/[^\d]/g, "");
            obj.value = tempstr;
        }
    </script>
    
</head>
<body>
    <form id="form1" runat="server" enctype="multipart/form-data">
    <input id="ProductId" name="ProductId" type="hidden" value="<%=ms.Id %>"/>
    <input id="ProductTitle" name="ProductTitle" type="hidden" value="<%=ms.Title %>"/>
    <div>
        <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="table_1">
            <tr>
                <td height="23" colspan="2" class="table_2">
                    添加 <asp:label runat="server" id="lbTypeName"><%=ms.Title%>的照片</asp:label>
                </td>
            </tr>
            <tr>
                <td >
                    照片名称:
                </td>
                <td >
                 <input type="text" name="Title" id="Title" size="140" />
                &nbsp;</td>
            </tr>
                <tr>
                <td >
                    上传照片:
                </td>
                <td >                 
                <input type='file' name="FilePath" id="FilePath"   onchange="onUploadImgChange(this,100,100);"/>
                  <div id="updateImage">
      <div id="preview_fake" class="preview_fake">      
      <img  alt="" class="preview_pic" src=""   width="100px" height="100px"/>      
      </div> 
      </div>         
                &nbsp;</td>
            </tr>
                <tr>
                <td >
                    排序:
                </td>
                <td >
                 <input type="text" name="SortId" id="SortId"   onkeyup="checkNum(this);" onblur="checkNum(this);"  />
                &nbsp;</td>
            </tr>
            <tr>
                    <td class="tdleft">
                       </td>
                    <td class="tdside">
                        <asp:Button ID="btnSave" runat="server" Text="保存" onclick="btnSave_Click"  OnClientClick="return save();" />                         
                    </td>
                </tr>
        </table>
    </div>
    </form>
</body>
</html>
